//文章分类页接口逻辑
const db = require("../lib/db");
function classifyArticleList(){
    return new Promise((resolve,reject)=>{
        let sql = "select * from classify where classify";
        db.querySql(sql).then(data=>{
            if(data.length==0){
                resolve(2002)
            }else{
                let srr = data.sort(()=>0.5-Math.random());
                let srr2 = []
                srr.map(element=>{
                    srr2.push({
                        _id:element.classify_id,
                        title:element.classify_title,
                        time:element.classify_time,
                        desc:element.classify_article_desc,
                        author:element.classify_author,
                        authorId:element.classify_authorId,
                        classify:element.classify_classify,
                        content:element.classify_content
                    })
                })
                resolve(srr2)
            }
        })
    })
}
module.exports = classifyArticleList